<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>条件渲染</title>
    <script src="./js/babel.min.js"></script>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <style>
      #ad{
        width: 300px;
        height: 300px;
        position: absolute;
        right: 0;
        bottom: 0;
        background: rgb(60, 199, 129);
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //声明变量
      let isVip = true;

      //创建虚拟DOM对象
      // let vdom = <div id="ad"></div>;

      //1. if...else  了解一下 用的非常少
      // let vdom = null;
      // if(!isVip){
      //   vdom = <div id="ad"></div>;
      // }

      //2. &&
      // let vdom = !isVip && <div id="ad"></div>;
      // let vdom = <div>
      //               {!isVip && <div id="ad"></div>}
      //           </div>

      //3. 三元运算符
      // let vdom = isVip ? null : <div id="ad"></div>;
      let vdom = <div>
                    {isVip ? null : <div id="ad"></div>}
                </div>

      //渲染
      ReactDOM.render(vdom, document.querySelector('#root'));
    </script>
  </body>
</html>
